<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="单号" prop="no">
        <el-input
          v-model="queryParams.no"
          placeholder="请输入单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="用户id" prop="client">-->
<!--        <el-input-->
<!--          v-model="queryParams.client"-->
<!--          placeholder="请输入用户id"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="进度" prop="oStage">-->
<!--        <el-select v-model="queryParams.oStage" placeholder="请选择进度" clearable>-->
<!--          <el-option-->
<!--            v-for="dict in dict.type.fo_assets_signing_order_o_stage"-->
<!--            :key="dict.value"-->
<!--            :label="dict.label"-->
<!--            :value="dict.value"-->
<!--          />-->
<!--        </el-select>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="取消进度" prop="cancelStage">-->
<!--        <el-select v-model="queryParams.cancelStage" placeholder="请选择取消进度" clearable>-->
<!--          <el-option-->
<!--            v-for="dict in dict.type.fo_assets_signing_order_cancel_stage"-->
<!--            :key="dict.value"-->
<!--            :label="dict.label"-->
<!--            :value="dict.value"-->
<!--          />-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item label="客户名称" prop="clientName">
        <el-input
          v-model="queryParams.clientName"
          placeholder="请输入客户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['yipaiju:house_uploading_order:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['yipaiju:house_uploading_order:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['yipaiju:house_uploading_order:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['yipaiju:house_uploading_order:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="house_uploading_orderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="id" align="center" prop="id" />-->
      <el-table-column label="单号" align="center" prop="no" />
<!--      <el-table-column label="用户id" align="center" prop="client" />-->
      <el-table-column label="签约进度" align="center" prop="oStage">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.fo_assets_signing_order_o_stage" :value="scope.row.oStage"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="取消进度" align="center" prop="cancelStage">-->
<!--        <template slot-scope="scope">-->
<!--          <dict-tag :options="dict.type.fo_assets_signing_order_cancel_stage" :value="scope.row.cancelStage"/>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="客户名称" align="center" prop="clientName" />
<!--      <el-table-column label="市场加入时间" align="center" prop="marketerJoinTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.marketerJoinTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="拍卖时间之前" align="center" prop="auctionBeforeTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.auctionBeforeTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="拍卖时间" align="center" prop="auctioningTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.auctioningTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="拍卖解除时间" align="center" prop="auctionDealTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.auctionDealTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="auction_after_time" align="center" prop="auctionAfterTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.auctionAfterTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="服务完成时间" align="center" prop="serviceFinishTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.serviceFinishTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="失败时间" align="center" prop="defeatTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.defeatTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="状态" align="center" prop="status">-->
<!--        <template slot-scope="scope">-->
<!--          <dict-tag :options="dict.type.fo_assets_signing_order_status" :value="scope.row.status"/>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="进度" align="center" prop="stage">-->
<!--        <template slot-scope="scope">-->
<!--          <dict-tag :options="dict.type.fo_assets_signing_order_stage" :value="scope.row.stage"/>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="市场专员" align="center" prop="marketer" />-->
      <el-table-column label="提交时间" align="center" prop="submitTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.submitTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="验证状态" align="center" prop="marketManagerVertifyStatus" />-->
<!--      <el-table-column label="验证完成时间" align="center" prop="marketManagerVerificationFinishTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.marketManagerVerificationFinishTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="提交状态" align="center" prop="submitStatus" />
<!--      <el-table-column label="merchant" align="center" prop="merchant" />-->
<!--      <el-table-column label="市场经理" align="center" prop="marketManager" />-->
      <el-table-column label="打星" align="center" prop="rate" />
      <el-table-column label="评论" align="center" prop="comment" />
<!--      <el-table-column label="discount_house_id" align="center" prop="discountHouseId" />-->
      <el-table-column label="驳回理由" align="center" prop="rejectReason" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['yipaiju:house_uploading_order:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['yipaiju:house_uploading_order:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改放盘签约订单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="单号" prop="no">
              <el-input v-model="form.no" placeholder="请输入单号" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="客户名称" prop="clientName">
              <el-input v-model="form.clientName" placeholder="请输入客户名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
          </el-col>
          <el-col :span="12">
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="签约进度" prop="oStage">
              <el-select v-model="form.oStage" placeholder="请选择进度">
                <el-option
                  v-for="dict in dict.type.fo_assets_signing_order_o_stage"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="服务进度" prop="stage">
              <el-select v-model="form.stage" placeholder="请选择进度">
                <el-option
                  v-for="dict in dict.type.fo_assets_signing_order_stage"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
<!--            <el-form-item label="取消进度" prop="cancelStage">-->
<!--              <el-select v-model="form.cancelStage" placeholder="请选择取消进度">-->
<!--                <el-option-->
<!--                  v-for="dict in dict.type.fo_assets_signing_order_cancel_stage"-->
<!--                  :key="dict.value"-->
<!--                  :label="dict.label"-->
<!--                  :value="parseInt(dict.value)"-->
<!--                ></el-option>-->
<!--              </el-select>-->
<!--            </el-form-item>-->
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="市场加入时间" prop="marketerJoinTime">
              <el-date-picker clearable
                              v-model="form.marketerJoinTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择市场加入时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拍卖之前时间" prop="auctionBeforeTime">
              <el-date-picker clearable
                              v-model="form.auctionBeforeTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择拍卖时间之前">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="拍卖时间" prop="auctioningTime">
              <el-date-picker clearable
                              v-model="form.auctioningTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择拍卖时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拍卖解除时间" prop="auctionDealTime">
              <el-date-picker clearable
                              v-model="form.auctionDealTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择拍卖解除时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="拍卖之后时间" prop="auctionAfterTime">
              <el-date-picker clearable
                              v-model="form.auctionAfterTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择拍卖之后时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="服务完成时间" prop="serviceFinishTime">
              <el-date-picker clearable
                              v-model="form.serviceFinishTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择服务完成时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
<!--        <el-row>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="失败时间" prop="defeatTime">-->
<!--              <el-date-picker clearable-->
<!--                              v-model="form.defeatTime"-->
<!--                              type="date"-->
<!--                              value-format="yyyy-MM-dd"-->
<!--                              placeholder="请选择失败时间">-->
<!--              </el-date-picker>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="状态" prop="status">-->
<!--              <el-select v-model="form.status" placeholder="请选择状态">-->
<!--                <el-option-->
<!--                  v-for="dict in dict.type.fo_assets_signing_order_status"-->
<!--                  :key="dict.value"-->
<!--                  :label="dict.label"-->
<!--                  :value="parseInt(dict.value)"-->
<!--                ></el-option>-->
<!--              </el-select>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->
<!--        <el-row>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="服务进度" prop="stage">-->
<!--              <el-select v-model="form.stage" placeholder="请选择进度">-->
<!--                <el-option-->
<!--                  v-for="dict in dict.type.fo_assets_signing_order_stage"-->
<!--                  :key="dict.value"-->
<!--                  :label="dict.label"-->
<!--                  :value="parseInt(dict.value)"-->
<!--                ></el-option>-->
<!--              </el-select>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="市场专员" prop="marketer">-->
<!--              <el-input v-model="form.marketer" placeholder="请输入市场专员" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->
        <el-row>
          <el-col :span="12">
            <el-form-item label="提交时间" prop="submitTime">
              <el-date-picker clearable
                              v-model="form.submitTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择提交时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="验证完成时间" prop="marketManagerVerificationFinishTime">
              <el-date-picker clearable
                              v-model="form.marketManagerVerificationFinishTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择验证完成时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
<!--            <el-form-item label="市场经理" prop="marketManager">-->
<!--              <el-input v-model="form.marketManager" placeholder="请输入市场经理" />-->
<!--            </el-form-item>-->
            <el-form-item label="打星" prop="rate">
              <el-input v-model="form.rate" placeholder="请输入打星" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="评论" prop="comment">
              <el-input v-model="form.comment" placeholder="请输入评论" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="驳回理由" prop="rejectReason">
          <el-input v-model="form.rejectReason" placeholder="请输入驳回理由" />
        </el-form-item>


<!--        <el-form-item label="用户id" prop="client">-->
<!--          <el-input v-model="form.client" placeholder="请输入用户id" />-->
<!--        </el-form-item>-->

<!--        <el-form-item label="merchant" prop="merchant">-->
<!--          <el-input v-model="form.merchant" placeholder="请输入merchant" />-->
<!--        </el-form-item>-->

<!--        <el-form-item label="discount_house_id" prop="discountHouseId">-->
<!--          <el-input v-model="form.discountHouseId" placeholder="请输入discount_house_id" />-->
<!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listHouse_uploading_order, getHouse_uploading_order, delHouse_uploading_order, addHouse_uploading_order, updateHouse_uploading_order } from "@/api/yipaiju/house_uploading_order";

export default {
  name: "House_uploading_order",
  dicts: ['fo_assets_signing_order_status', 'fo_assets_signing_order_o_stage', 'fo_assets_signing_order_cancel_stage', 'fo_assets_signing_order_stage'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 放盘签约订单表格数据
      house_uploading_orderList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        no: null,
        client: null,
        oStage: null,
        cancelStage: null,
        clientName: null,
        marketerJoinTime: null,
        auctionBeforeTime: null,
        auctioningTime: null,
        auctionDealTime: null,
        auctionAfterTime: null,
        serviceFinishTime: null,
        defeatTime: null,
        status: null,
        stage: null,
        marketer: null,
        submitTime: null,
        marketManagerVertifyStatus: null,
        marketManagerVerificationFinishTime: null,
        submitStatus: null,
        merchant: null,
        marketManager: null,
        rate: null,
        comment: null,
        discountHouseId: null,
        rejectReason: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询放盘签约订单列表 */
    getList() {
      this.loading = true;
      listHouse_uploading_order(this.queryParams).then(response => {
        this.house_uploading_orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        no: null,
        client: null,
        oStage: null,
        cancelStage: null,
        clientName: null,
        createTime: null,
        marketerJoinTime: null,
        auctionBeforeTime: null,
        auctioningTime: null,
        auctionDealTime: null,
        auctionAfterTime: null,
        serviceFinishTime: null,
        defeatTime: null,
        status: null,
        stage: null,
        marketer: null,
        submitTime: null,
        marketManagerVertifyStatus: 0,
        marketManagerVerificationFinishTime: null,
        submitStatus: 0,
        merchant: null,
        marketManager: null,
        rate: null,
        comment: null,
        discountHouseId: null,
        rejectReason: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加放盘签约订单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getHouse_uploading_order(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改放盘签约订单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateHouse_uploading_order(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addHouse_uploading_order(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除放盘签约订单编号为"' + ids + '"的数据项？').then(function() {
        return delHouse_uploading_order(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('yipaiju/house_uploading_order/export', {
        ...this.queryParams
      }, `house_uploading_order_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
